<template>
    <router-link to="/business/base/profile">
        <div class="myBox">
            <div class="L"><img :src="business.avatar_cdn" /></div>
            <div class="C">
                <div class="tit">{{ business.nickname ? business.nickname : business.mobile_text }}</div>
                <div class="sub" v-if="business.nickname">{{ business.mobile_text }}</div>
            </div>
            <div class="R"><img src="/assets/images/go.png" /></div>
        </div>
    </router-link>
    <div class="clear"></div>
    <div class="allkbox"></div>
    <router-link to="/business/base/profile">
        <div class="myboxcon">
            <p>基本资料</p>
            <img src="/assets/images/go.png">
        </div>
    </router-link>
    <router-link to="/business/email/index" v-if="business.email && business.auth != 1">
        <div class="myboxcon">
            <p>邮箱认证</p>
            <img src="/assets/images/go.png">
        </div>
    </router-link>
    <router-link to="/business/address/index">
        <div class="myboxcon">
            <p>我的收货地址</p>
            <img src="/assets/images/go.png">
        </div>
    </router-link>
    <router-link to="/product/order/Index">
        <div class="myboxcon">
            <p>我的订单</p>
            <img src="/assets/images/go.png">
        </div>
    </router-link>
    <router-link to="/business/collection/Index">
        <div class="myboxcon">
            <p>我的收藏</p>
            <img src="/assets/images/go.png">
        </div>
    </router-link>
    <router-link to="/business/pay/index">
        <div class="myboxcon">
            <p>充值</p>
            <img src="/assets/images/go.png">
        </div>
    </router-link>
    <div class="myboxcon" @click="onLogout">
        <p>退出账号</p>
        <img src="/assets/images/go.png">
    </div>

    <div class="clear"></div>
    <div class="h54"></div>
    <div class="clear"></div>

    <Footer />
</template>

<script setup>
import Footer from 'components/common/Footer.vue';
import { reactive, getCurrentInstance } from 'vue';

const { proxy } = getCurrentInstance();
const business = reactive(proxy.$cookies.get('business') ?? {});

const onLogout = () => {
    proxy.$showConfirmDialog({
        title: '取消',
        message: '退出当前账号',
    }).then(() => {
        proxy.$showNotify({
            type: 'success',
            message: '退出成功',
            duration: 2000,
            onClose: () => {
                proxy.$cookies.remove('business');

                proxy.$router.push('/business/base/login');
            }
        })
    }).catch(() => {
        proxy.$showNotify({
            type: 'success',
            message: '取消成功',
            duration: 2000,
        })
    });
}
</script>
<style scoped>
.form {
    padding: 0px;
    background: none;
}
</style>